package org.bridge.db.dao;

import java.io.IOException;
import java.io.StringWriter;
import java.sql.SQLException;

import junit.framework.TestCase;

import org.bridge.db.bean.xml.DbParam;
import org.bridge.db.bean.xml.Query;
import org.exolab.castor.core.exceptions.CastorException;
import org.exolab.castor.mapping.Mapping;
import org.xml.sax.InputSource;

public class DAOServiceTest extends TestCase {

//	public void testFind() {
//		DAOService dao = new DAOService();
//		Query query = new Query();
//		query.setName("esitoInterrogazioni");
//		query.setSql("select * from INTERROGAZIONI_ESITO where TIPO_ESITO=?");
//		DbParam param1 = new DbParam();
//		param1.setPos(1);
//		param1.setValue("1");
//		query.addParam(param1);
//		
//		Mapping mapping = new Mapping();
//		mapping.loadMapping(new InputSource(DAOServiceTest.class.getResourceAsStream("/query.cm.xml")));
//		
//		try {
//			System.out.println(dao.find(query));
//		} catch (Exception e) {
//			// TODO Auto-generated catch block
//			e.printStackTrace();
//		}
//		
//	}
	
	public void testFindXmlResultSet() throws SQLException, IOException, CastorException{
		Query qry = new Query();
		qry.setSql("select * from USERS where NICKNAME=?");
		DbParam param = new DbParam();
		param.setPos(1);
		param.setValue("pardo");
		qry.addParam(param);
		
		DAOService daoService = new DAOService(null);
		byte[] b = daoService.findXmlResultSet(qry);
		System.out.println(new String(b));
	}

}
